package cn.krund.lyc.hotlerobot.activity.ui;

import android.content.Context;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.ButterKnife;
import cn.krund.lyc.hotlerobot.R;
import cn.krund.lyc.hotlerobot.activity.base.BaseActivity;
import cn.krund.lyc.hotlerobot.utils.KrundLog;
import cn.krund.lyc.hotlerobot.utils.ToastUtils;

/**
 * @包名: cn.krund.lyc.hotlerobot.activity.ui
 * @作者: 刘育成
 * @时间: 2018/3/26  17:57
 * @org: 克路德人工智能
 * @描述: TODO
 * @fileName: DeliveryPatternActivity
 */

public class DeliveryPatternActivity extends BaseActivity implements View.OnClickListener {

    @BindView(R.id.tv_back)
    TextView mTvBack;
    @BindView(R.id.tv_title)
    TextView mTvTitle;
    @BindView(R.id.et_confirm_up)
    EditText mEtConfirmUp;
    @BindView(R.id.btn_confirm_up)
    Button mBtnConfirmUp;
    @BindView(R.id.et_confirm_down)
    EditText mEtConfirmDown;
    @BindView(R.id.btn_confirm_down)
    Button mBtnConfirmDown;
    @BindView(R.id.btn_send_confirm)
    Button mBtnSendConfirm;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_delivery_pattern;
    }

    @Override
    protected void initView() {
        mTvTitle.setText("送货模式");
        mTvBack.setOnClickListener(this);
        mTvTitle.setOnClickListener(this);
        mBtnSendConfirm.setOnClickListener(this);
    }

    @Override
    protected void initNev() {
        mEtConfirmUp.setOnEditorActionListener(mListener);
        mEtConfirmDown.setOnEditorActionListener(mListener);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_back:
                finish();
                break;
            case R.id.btn_send_confirm:
                openActivity(StandbyModeActivity.class);
                break;
        }
    }
    TextView.OnEditorActionListener mListener=new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId== EditorInfo.IME_ACTION_DONE){
                //隐藏软键盘
                InputMethodManager imm = (InputMethodManager) v
                        .getContext().getSystemService(
                                Context.INPUT_METHOD_SERVICE);
                if (imm.isActive()) {
                    imm.hideSoftInputFromWindow(
                            v.getApplicationWindowToken(), 0);
                }
                ToastUtils.showShortToast(DeliveryPatternActivity.this,"11111111");
            }
            return false;
        }
    };
}
